package server.content.abilities;

import server.game.players.Client;

public class BananaPicking {

	private final Client c;
	private BananaTree currentTree = null;

	public BananaPicking(final Client c) {
		this.c = c;
	}

	public void pickTree(final int treeId, final int treeX, final int treeY) {
		if (System.currentTimeMillis() - c.lastThieve < 2000) {
			return;
		}
		if (c.getItems().freeSlots() < 1) {
			c.sendMessage("Your inventory is to full to pick any more bananas.");
			return;
		}
		if (!BananaTreeHandler.treeExists(treeX, treeY)) {
			BananaTreeHandler.addTree(c, treeId, new int[] { treeX, treeY });
			return;
		} else {
			currentTree = BananaTreeHandler.getTree(treeX, treeY);
		}
		if (currentTree == null)
			return;
		switch (treeId) {
		case 2073: // 5
		case 2074: // 4
		case 2075: // 3
		case 2076: // 2
		case 2077: // 1
		case 2078: // 0
			currentTree.takeBanana();
			c.lastThieve = System.currentTimeMillis();
			break;

		}
	}

}
